home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet internetowy / Przegladarki internetowe / Mozilla Seamonkey 1.0.5 pl / seamonkey-1.0.5.pl-PL.win32.installer.exe / MAIL.XPI / bin / chrome / messenger.jar / content / messenger-mapi / pref-mailnewsOverlay.js < prev    next >
Encoding:
JavaScript  |  2005-06-07  |  4.7 KB  |  120 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is mozilla.org code.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Netscape Communications Corporation.
  18.  * Portions created by the Initial Developer are Copyright (C) 2001
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s): 
  22.  *   Srilatha Moturi <srilatha@netscape.com>
  23.  *   Rajiv Dayal <rdayal@netscape.com>
  24.  *   Ian Neal <bugzilla@arlen.demon.co.uk>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  28.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. function mailnewsOverlayStartup()
  41. {
  42.   if (!("mapiInitialized" in parent))
  43.   {
  44.     parent.mapiDisabled = true;
  45.     parent.newsDisabled = true;
  46.     var mapiRegistry = getMapiRegistry();
  47.     parent.mapiInitialized = !!mapiRegistry;
  48.     if (mapiRegistry)
  49.     {
  50.       var prefWindow = parent.hPrefWindow;
  51.       // initialise preference and registry components.
  52.       // While the data is coming from the system registry, we use a set
  53.       // of parallel preferences to indicate if the ui should be locked.
  54.       parent.mapiPref = {};
  55.       parent.mapiReg = {};
  56.  
  57.       // Only register callback if mapiRegistry exists so
  58.       // we do not need to check its existence in onOK
  59.       prefWindow.registerOKCallbackFunc(onOK);
  60.  
  61.       var isDefault;
  62.       const kPrefBase = "system.windows.lock_ui.";
  63.       if (prefWindow.getPrefIsLocked(kPrefBase + "defaultMailClient"))
  64.       {
  65.         isDefault = prefWindow.getPref("bool", kPrefBase + "defaultMailClient");
  66.         mapiRegistry.isDefaultMailClient = isDefault;
  67.         parent.mapiReg.isDefaultMailClient = isDefault;
  68.       }
  69.       else
  70.       {
  71.         parent.mapiReg.isDefaultMailClient = mapiRegistry.isDefaultMailClient;
  72.         parent.mapiDisabled = false;
  73.       }
  74.       parent.mapiPref.isDefaultMailClient = parent.mapiReg.isDefaultMailClient;
  75.  
  76.       if (prefWindow.getPrefIsLocked(kPrefBase + "defaultNewsClient"))
  77.       {
  78.         isDefault = prefWindow.getPref("bool", kPrefBase + "defaultNewsClient");
  79.         mapiRegistry.isDefaultNewsClient = isDefault;
  80.         parent.mapiReg.isDefaultNewsClient = isDefault;
  81.       }
  82.       else
  83.       {
  84.         parent.mapiReg.isDefaultNewsClient = mapiRegistry.isDefaultNewsClient;
  85.         parent.newsDisabled = false;
  86.       }
  87.       parent.mapiPref.isDefaultNewsClient = parent.mapiReg.isDefaultNewsClient;
  88.     }
  89.   }
  90.  
  91.   var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
  92.   var mailnewsEnableNews = document.getElementById("mailnewsEnableNews");
  93.  
  94.   if (parent.mapiInitialized)
  95.   {
  96.     // when we switch between different panes set the checkbox based on the saved state
  97.     mailnewsEnableMapi.checked = parent.mapiPref.isDefaultMailClient;
  98.     mailnewsEnableNews.checked = parent.mapiPref.isDefaultNewsClient;
  99.   }
  100.   mailnewsEnableMapi.disabled = parent.mapiDisabled;
  101.   mailnewsEnableNews.disabled = parent.newsDisabled;
  102. }
  103.  
  104. function getMapiRegistry() {
  105.   if ("@mozilla.org/mapiregistry;1" in Components.classes)
  106.     return Components.classes["@mozilla.org/mapiregistry;1"]
  107.                      .getService(Components.interfaces.nsIMapiRegistry);
  108.   return null;
  109. }
  110.  
  111. function onOK()
  112. {
  113.   var mapiRegistry = getMapiRegistry();
  114.   if (parent.mapiReg.isDefaultMailClient != parent.mapiPref.isDefaultMailClient)
  115.     mapiRegistry.isDefaultMailClient = parent.mapiPref.isDefaultMailClient;
  116.  
  117.   if (parent.mapiReg.isDefaultNewsClient != parent.mapiPref.isDefaultNewsClient)
  118.     mapiRegistry.isDefaultNewsClient = parent.mapiPref.isDefaultNewsClient;
  119. }
  120.